/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - T6
 * <p>Powered by webrx On 2022-01-27 14:14:58
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T6 {
    public static void main(String[] args) {
        //定时操作
        var t = new Thread(() -> {
            //{} 就是run()方法实现
            while (true) {
                try {
                    Thread.sleep(5000);
                    System.out.printf("%tF %<tT%n", System.currentTimeMillis());
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }
        }, "test1");

        //t.start();

        //如下线程是60秒后关机
        var ok = new Thread(() -> {
            System.out.println("关机程序启动...");
            try {
                TimeUnit.DAYS.sleep(60);
                System.out.println("开始关机");
                //关机代码
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, "ok");
        ok.start();
    }
}
